<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    #yuan{
        background: green;
        width: 100px;
        height: 100px;
        border-radius: 50%;
    }
</style>
<body>
    <div id="yuan"></div>
    <script>
        function sleep(duration){
            return new Promise(function(resolve){
                setTimeout(resolve, duration);
            })
        }
        async function changeColor(duration,color){
            document.getElementById("yuan").style.background = color;
            await sleep(duration);
        }
        async function main(){
            while(true){
                await changeColor(3000,"green");
                await changeColor(1000, "yellow");
                await changeColor(2000, "red");
            }
        }
        main();
    </script>
</body>
</html>